package com.baiye.template.service.impl;

import com.alipay.api.AlipayApiException;
import com.baiye.template.dao.PayDao;
import com.baiye.template.pojo.OrderVo;
import com.baiye.template.service.PayService;
import com.baiye.template.utils.AlipayUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.UUID;

/**
 * @author GUOZHIPENG
 * @version 1.0
 * @date 2021/9/17 11:50
 */
@Service
public class PayServiceImpl implements PayService {
    @Autowired
    private PayDao payDao;
    @Override
    public String aliPay(OrderVo orderVo){
        orderVo.setSubject("打赏");
        orderVo.setOut_trade_no(System.currentTimeMillis()+"");
        payDao.saveOrder(orderVo);
        return AlipayUtil.connect(orderVo);
    }

    @Override
    public int finishOrder(String out_trade_no) {
        return payDao.finishOrder(out_trade_no);
    }
}
